package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.User;
import com.cskaoyan.bean.basebean.BaseRespVo;
import com.cskaoyan.bean.wx_search.UserIndex;
import com.cskaoyan.service.OrderService;
import com.cskaoyan.service.UserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("wx/user")
public class WxUserController {
    @Autowired
    UserService userService;

    @Autowired
    OrderService orderService;

    //zhao：订单右上角的小图标显示不出来
    @RequestMapping("index")
    public BaseRespVo userIndex(){
        Subject subject = SecurityUtils.getSubject();
        User tokenUser = (User) subject.getPrincipals().getPrimaryPrincipal();
        User user = userService.selectUserByUsername(tokenUser.getUsername());
        UserIndex userIndex = orderService.selectOrderStatusNumByUserId(user.getId());
        return BaseRespVo.ok(userIndex);
    }
}
